home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / IsoPalette.pprx < prev    next >
Text File  |  1997-05-06  |  2KB  |  106 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1995-1997 Cloanto Italia srl */
  2.  
  3. /* $VER: IsoPalette.pprx 1.0 */
  4.  
  5. /** ENG
  6.   This script generates an iso-palette composed of equally-spaced colors
  7.   in the color cube (color mode) or a grayscale palette (gray mode).
  8. */
  9.  
  10. /** DEU
  11.  Dieses Skript dient zum Erzeugen einer sog. "ISO-Palette", d. h.
  12.  einer Farbpalette, in der alle Farbtöne gleichmäßig über den Farbraum
  13.  des Farbwürfels (im Farbmodus) oder der Graustufenpalette (im 
  14.  Graustufenmodus) verteilt sind.
  15. */
  16.  
  17. /** ITA
  18.   Questo script genera una iso-palette composta da colori disposti a distanza
  19.   eguale nello spazio cubico dei colori (modo colore) o una tavolozza a toni di
  20.   grigio (modo grigio).
  21. */
  22.  
  23. IF ARG(1, EXISTS) THEN
  24.     PARSE ARG PPPORT graymode
  25. ELSE DO
  26.     PPPORT = 'PPAINT'
  27.     graymode = 0
  28. END
  29.  
  30. IF ~SHOW('P', PPPORT) THEN DO
  31.     IF EXISTS('PPaint:PPaint') THEN DO
  32.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  33.         DO 30 WHILE ~SHOW('P',PPPORT)
  34.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  35.         END
  36.     END
  37.     ELSE DO
  38.         SAY "Personal Paint could not be loaded."
  39.         EXIT 10
  40.     END
  41. END
  42.  
  43. IF ~SHOW('P', PPPORT) THEN DO
  44.     SAY 'Personal Paint Rexx port could not be opened'
  45.     EXIT 10
  46. END
  47.  
  48. ADDRESS VALUE PPPORT
  49. OPTIONS RESULTS
  50. OPTIONS FAILAT 10000
  51.  
  52. LockGUI
  53.  
  54. /*         Entries  R G B  Clrs Grays  */
  55. /*         --------------------------  */
  56. colorset.0 = '256   7 7 5  245   11'
  57. colorset.1 = '128   5 6 4  120   8 '
  58. colorset.2 = '64    4 5 3   60   4 '
  59. colorset.3 = '32    3 3 3   27   5 '
  60. colorset.4 = '16    2 3 2   12   4 '
  61. colorset.5 = '8     2 2 2    8   0 '
  62.  
  63.  
  64. Get 'COLORS'
  65. cnum = RESULT
  66. DO set = 0 to 5
  67.     PARSE VAR colorset.set cn rbits gbits bbits . gnum .
  68.     IF cn = cnum THEN
  69.         LEAVE
  70. END
  71. IF set > 5 THEN
  72.     graymode = 1
  73.  
  74. palette = ''
  75. IF graymode = 0 THEN DO
  76.     rstep = 255 / (rbits - 1)
  77.     gstep = 255 / (gbits - 1)
  78.     bstep = 255 / (bbits - 1)
  79.  
  80.     DO red = 0 TO 255 BY rstep
  81.         DO green = 0 TO 255 BY gstep
  82.             DO blue = 0 TO 255 BY bstep
  83.                 palette = palette TRUNC(red + 0.5) TRUNC(green + 0.5) TRUNC(blue + 0.5)
  84.             END
  85.         END
  86.     END
  87.     IF gnum > 0 THEN DO
  88.         gstep = 255 / (gnum + 1)
  89.         DO gry = gstep TO 255-gstep BY gstep
  90.             igry = TRUNC(gry + 0.5)
  91.             palette = palette igry igry igry
  92.         END
  93.     END
  94. END
  95. ELSE DO
  96.     gstep = 255 / (cnum - 1)
  97.     DO gry = 0 TO 255 BY gstep
  98.         igry = TRUNC(gry + 0.5)
  99.         palette = palette igry igry igry
  100.     END
  101. END
  102.  
  103. SetColors 'COLORS "'palette'"'
  104.  
  105. UnlockGUI
  106.